package com.kira.scaffoldmvc.Mapper;

import com.kira.scaffoldmvc.POJO.Result;
import com.kira.scaffoldmvc.POJO.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {


    @Insert("INSERT INTO user (name, password, account, `right`, ban, user_id) VALUES (#{name}, #{password}, #{account}, 0, 0, #{userId})")
    boolean registry(String name, String password, String account,String userId);

//    @Select("select * from user where account=#{account} and password=#{password}")
//    User login(String account, String password);

    @Select("select * from user where account= #{account} ")
   User selectByAccount(String account);

    @Update("update user set ban=1 where user_id=#{userId}")
    void lock(String userId);

    @Update("update user set ban=0 where user_id=#{userId}")
    void unlock(String userId);

    @Update("update user set `right`=#{code} where user_id=#{userId}")
    void setRight(Integer code, String userId);

    @Select("select `right` from user where user_id=#{myUserId}")
    Integer selectRight(String myUserId);

    @Select("select * from user ")
    List<User> getAllUser();

    @Select("select * from user where user_id=#{userId}")
    User getUserById(String userId);

    void check(String userId);
}
